#ifndef MESSAGESMODEL_H
#define MESSAGESMODEL_H

#include "../global/xnamespace.h"
#include "submodel/MessageModel.h"

#include <QQmlListProperty>

class QQmlEngine;
class QJSEngine;

X_BEGIN_NAMESPACE

// 消息集合模型，作为总的消息管理器，为会话提供消息查询功能，另外
// 会话本身也提供了查询功能
class MessagesManager : public QObject
{
    Q_OBJECT

signals:

public:
    explicit MessagesManager(QObject *parent = 0);

public:
    static MessagesManager &instance();
    static const char *qmlName();
    static QObject *qmlInstance(QQmlEngine* engine, QJSEngine* jsEngine);

    static int nextMessageId();

public slots:

private:
    void loadDataFromDb();

    static MessagesManager *createInstance();

private:
    static const char READ_MAX_MESSAGE_ID[];
    static QAtomicInt NEXT_MESSAGE_ID;
};

X_END_NAMESPACE

#endif // MESSAGESMODEL_H
